home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / editors / ted15 / tfix.pas < prev   
Pascal/Delphi Source File  |  1987-04-13  |  3KB  |  92 lines

  1. Program TFix;
  2.  
  3. {$I-}
  4.  
  5. Type
  6.   Str2     = String[2];
  7.   Str8     = String[8];
  8.   Str16    = String[16];
  9.   FileName = String[64];
  10.   FileRec  = record
  11.                Ch: Char;
  12.              End;
  13.  
  14. Var
  15.   TedFile        : File of FileRec;
  16.   TedRec         : FileRec;
  17.   Name1          : FileName;
  18.   I,DecBytes     : Integer;
  19.   Ans            : Char;
  20.   HexBytes,Work  : Str2;
  21.  
  22. Function HexStrToDec(HexStr:Str8):Real;
  23. Var HexChars : Str16;
  24.     R: Real;
  25.   Procedure Compute(CompI: Real; CompJ: Integer);
  26.   Begin
  27.     R := ((Pos(HexStr[CompJ],HexChars)-1)*CompI) + R;
  28.     If CompJ <> 1 then Compute(CompI*16,CompJ-1);
  29.   End;  {  Compute  }
  30. Begin                                          { I = incrementor   }
  31.   HexChars := '0123456789ABCDEF';              { J = pos in string }
  32.   R := 0.0;
  33.   Compute(1,Length(HexStr));
  34.   HexStrToDec := R;
  35. End;  {  HexStrToDec  }
  36.  
  37. Function DecToHexStr(Val:Integer):Str2;
  38. Const Digits : Array [ 0..15 ] of Char = '0123456789ABCDEF';
  39. Begin
  40.   DecToHexStr := Digits[ Val Div 16 ] +
  41.                  Digits[ Val Mod 16 ];
  42. End;  {  Hex  }
  43.  
  44. BEGIN
  45.   TedRec.Ch := ' ';
  46.   ClrScr;
  47.   GotoXY(1,5);
  48.   WriteLn('This program will modify the stack/heap size of a Turbo Pascal');
  49.   WriteLn('program.  It saves recompiling the program but beware, it modifies');
  50.   WriteLn('the COM file and changes the size in 64K increments.  If the value');
  51.   WriteLn('entered is not a valid Hex digit then ''A'' is used.');
  52.   WriteLn;
  53.   Write('Turbo COM file name: ');
  54.   Readln(Name1); WriteLn;
  55.   Assign(TedFile,Name1);
  56.   Reset(TedFile);
  57.   If IOResult <> 0 then begin
  58.     Close(TedFile);
  59.     Writeln('Error -- From file not found: ',Name1);
  60.     Halt;
  61.   End;
  62.   With TedRec do begin
  63. (*    I := 11404;   { 11403 }       { TURBO 3.01 }*)
  64.     I := 11357;   { 11356 }       { TURBO 3.01B }
  65.     Seek(TedFile,I);                          { Goto location to patch }
  66.  
  67.     Read(TedFile,TedRec);
  68.     Work := DecToHexStr(Lo(Ord(Ch)));
  69.     WriteLn('Currect stack/heap size(hex) = ',Copy(Work,1,1),' 64K blocks.');
  70.     Seek(TedFile,I);
  71.     WriteLn;
  72.     Write('Max. Stack/Heap size Bytes: ');
  73.  
  74.     Read(HexBytes);
  75.     For I := 1 to Length(HexBytes) do HexBytes[I] := UpCase(HexBytes[I]);
  76.  
  77.     HexBytes := HexBytes + '0';
  78.     If Not (HexBytes[I] in ['0'..'9']) and Not (HexBytes[I] in ['A'..'F']) then
  79.       HexBytes[I] := 'A';
  80.     Ch := Chr(Ord(Trunc(HexStrToDec(Copy(HexBytes,1,2)))));
  81.                                        { Setup byte }
  82.  
  83.     Write(TedFile,TedRec);             {  Patch in max. stack/heap size }
  84.     Close(TedFile);                    { We're Done }
  85.  
  86.     WriteLn;
  87.     WriteLn;
  88.     WriteLn(Name1,' Modified!');
  89.   End;
  90.  
  91. End.
  92.